﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
using DapperExtensions.Mapper;
using Newtonsoft.Json;

namespace MaximServices.Model
{
    public class Motto
    {
        public string Id { get; set; }

        public string Auth_Name { get; set; }

        public string Motto_Content { get; set; }

        public string Source { get; set; }

        public string Baike_Url { get; set; }

        public string TagList { get; set; }

        public string Status { get; set; }

        public DateTime Create_Time { get; set; }

        public DateTime Modify_Time { get; set; }

        [JsonIgnore]
        public MottoBaike BaikeInfo { get; set; }

        public string Content_Lite { get; set; }
    }

    public class MottoMapper : ClassMapper<Motto>
    {
        public MottoMapper()
        {

            //use different table name
            Table("motto");

            //use a custom schema
            Schema("");

            //have a custom primary key
            Map(x => x.Id).Column("id").Key(KeyType.Assigned);

            Map(x => x.Auth_Name).Column("auth_name");
            Map(x => x.Motto_Content).Column("motto_content");
            Map(x => x.Baike_Url).Column("baike_url");
            Map(x => x.TagList).Column("taglist");
            Map(x => x.Status).Column("status");
            Map(x => x.Create_Time).Column("create_time");
            Map(x => x.Modify_Time).Column("modify_time");
            Map(x => x.Content_Lite).Column("content_lite");

            Map(x => x.BaikeInfo).Ignore();

            //optional, map all other columns
            //AutoMap();
        }
    }
}
